package com.ghost.view.pop.task
{
	import com.ghost.UI.Ghost_Btn;
	import com.ghost.UI.Ghost_mc_scroll;
	import com.ghost.interfaces.Ibaseui;
	import com.ghost.model.Global_data;
	import com.ghost.model.Object_pool;
	import com.ghost.model.UI_skin_data;
	import com.ghost.utils.MovieClipUtil;
	import com.ghost.view.Base_effect;
	
	import flash.display.Bitmap;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	public class Task_trace extends Base_effect implements Ibaseui
	{
		private var control_btn:Ghost_Btn;//控制显示消失按钮
		private var view_mc:Sprite;//存放除控制按钮以外的容器
		private var task_trace_mc:Sprite;//存放所有cell的容器
		private var task_trace_cell:Task_trace_cell;//cell
		
		public function Task_trace()
		{
			view_mc = new Sprite();
			this.addChild(view_mc);
			view_mc.visible = false;
			var title_icon_b:Bitmap = new Bitmap(Object_pool.loaded_obj_pool.get("bottom_menu_ui").get("bottom_task_over"));
			view_mc.addChild(title_icon_b);
			var view_mc_bg:Bitmap = new Bitmap(Object_pool.loaded_obj_pool.get("task_trace_ui").get("task_trace_bg"));
			view_mc_bg.height = 200;
			view_mc_bg.width = 240;
			view_mc_bg.y = title_icon_b.height;
			view_mc.addChild(view_mc_bg);
			
			task_trace_mc = new Sprite();
			view_mc.addChild(task_trace_mc);
			task_trace_mc.y=title_icon_b.height;
			
			control_btn = new Ghost_Btn(UI_skin_data.ghost_btn_skin_v,control_Handler);
			control_btn.setsize(97,28);
			control_btn.label="显示任务追踪";
			this.addChild(control_btn);
			control_btn.x = this.width-control_btn.width;
			control_btn.y = title_icon_b.height-control_btn.height-1;
			update([1,2,3,4,5,6]);
		}
		public function update(data:Array):void
		{
			MovieClipUtil.removeAllChild(task_trace_mc);
			var l:int = data.length;
			if(l!=0)show_hide(false);
			var i:int = 0;
			trace(this.width,999);
			for(;i<l;i++)
			{
				task_trace_cell = new Task_trace_cell(this.width);
				task_trace_cell.y = task_trace_mc.height+2;
				task_trace_mc.addChild(task_trace_cell);
			}
			task_trace_mc.scrollRect=new Rectangle(0,0,task_trace_mc.width,200);
			var mc_scroll:Ghost_mc_scroll = new Ghost_mc_scroll(UI_skin_data.ghost_scroll_skin_v);
			view_mc.addChild(mc_scroll);
			mc_scroll.target = task_trace_mc;
			mc_scroll.move_to(task_trace_mc.x+task_trace_mc.width,task_trace_mc.y);
			mc_scroll.mouse_wheel = true;
		}
		private function control_Handler(e:MouseEvent):void
		{
			show_hide(view_mc.visible);
		}
		private function show_hide(bool:Boolean):void
		{
			if(bool)
			{
				view_mc.visible = false;
				control_btn.label="显示任务追踪";
			}
			else
			{
				view_mc.visible = true;
				control_btn.label="隐藏任务追踪";
			}
		}
		public function reflash_x_y(e:*):void
		{
			this.x = Global_data.stage_s_width-this.width;
			this.y = Global_data.stage_s_height/3-this.height/3;
		}
		public function hide():void
		{
			this.visible = false;
		}
		public function show():void
		{
			this.visible = true;
		}
	}
}